package testLayer;

import static org.junit.Assert.*;
import modelLayer.Customer;
import modelLayer.Supplier;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * This class is a JUnit test case of the Supplier class.
 * 
 * @author A. Kelemen
 * @Version 1.1
 * 
 */
public class SupplierTest {
	
	private Supplier supplier;
	
	/**
	 * Initializes a test object.
	 * 
	 * @throws Exception
	 */
	@Before
	public void setUp() throws Exception {
		
		this.supplier = new Supplier(2, "Sune Salamonsen", "Bygade 88", "Byen", "Landet", "12345678", "sune@salamonsen.dk", 1234);

	}

	@After
	public void tearDown() throws Exception {
		
		
		
	}
	
	/**
	 * Tests the constructor with parameters taking the parameters of the test object.
	 */
	@Test
	public void testSupplierWithParameters() {
		
		assertTrue(this.supplier != null);
		
	}
	
	/**
	 * Tests the empty constructor without parameters. Initializes a new person object.
	 */
	@Test
	public void testSupplier() {
		
		this.supplier = new Supplier();
		assertTrue(this.supplier != null);
		
	}
	
	/**
	 * Tests the constructor with an incorrect integer value. 
	 * This test method expects an exception and asserts true if an exception has been thrown.
	 */
	@Test (expected = IllegalArgumentException.class)
	public void testCustomerThrowsExceptionWrongID() {
		
		this.supplier = new Supplier(2, "Sune Salamonsen", "Bygade 88", "Byen", "Landet", "12345678", "sune@salamonsen.dk", 12340);

	}
	
	/**
	 * Tests the constructor with an incorrect String value. 
	 * This test method expects an exception and asserts true if an exception has been thrown.
	 */
	@Test (expected = IllegalArgumentException.class)
	public void testCustomerThrowsExceptionWrongString() {
		
		this.supplier = new Supplier(2, "", "Bygade 88", "Byen", "Landet", "12345678", "sune@salamonsen.dk", 1234);

	}
	
	/**
	 * Tests if the value of the getSupplierID() method equals the expected supplierID value of the test object.
	 */
	@Test
	public void testGetSupplierID() {
		
		assertEquals(2, this.supplier.getSupplierID());
		
	}

}
